home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 October / Enter 10 2006.iso / boot / isolinux / initrd / in / usr / lib / setup / SeTswap < prev    next >
Encoding:
Text File  |  2006-07-17  |  3.2 KB  |  82 lines

  1. #!/bin/sh
  2. TMP=/var/log/setup/tmp
  3. export TEXTDOMAIN=SeTswap
  4. if [ ! -d $TMP ]; then
  5.   mkdir -p $TMP
  6. fi
  7. REDIR=/dev/tty4
  8. NDIR=/dev/null
  9. crunch() {
  10.  read STRING;
  11.  echo $STRING;
  12. }
  13. rm -f $TMP/SeTswap $TMP/SeTswapskip
  14. SWAPLIST="`probe -l | fgrep "Linux swap" | sort 2> $NDIR`" 
  15. if [ "$SWAPLIST" = "" ]; then
  16.  dialog --title "`gettext "NO SWAP SPACE DETECTED"`" --yesno "`gettext "You have not created \
  17. a swap partition with Linux fdisk.  \
  18. Do you want to continue installing without one? "`" 6 60
  19.  if [ "$?" = "1" ]; then
  20.   dialog --title "`gettext "ABORTING INSTALLATION"`" --msgbox "`gettext "Create a swap partition with Linux fdisk, and then try this again."`" \
  21. 6 40
  22.  else
  23.   touch $TMP/SeTswapskip
  24.  fi
  25.  exit
  26. else # there is at least one swap partition:
  27.  echo > $TMP/swapmsg 
  28.  if [ "`echo "$SWAPLIST" | sed -n '2 p'`" = "" ]; then
  29.   echo "`gettext "Kate OS Setup has detected a swap partition:"`" >> $TMP/swapmsg
  30.   echo >> $TMP/swapmsg
  31.   echo "   Device Boot    Start       End    Blocks   Id  System\\n" >> $TMP/swapmsg
  32.   echo "`echo "$SWAPLIST" | sed -n '1 p'`\\n" >> $TMP/swapmsg
  33.   echo >> $TMP/swapmsg
  34.   echo "`gettext "Do you wish to install this as your swap partition?"`" >> $TMP/swapmsg
  35.   dialog --title "`gettext "SWAP SPACE DETECTED"`" --cr-wrap --yesno "`cat $TMP/swapmsg`" 12 70
  36.   REPLY=$?
  37.  else
  38.   echo "`gettext "Kate OS Setup has detected the following swap partitions:"`" >> $TMP/swapmsg
  39.   echo >> $TMP/swapmsg
  40.   echo "   Device Boot    Start       End    Blocks   Id  System\\n" >> $TMP/swapmsg
  41.   echo "$SWAPLIST\\n" >> $TMP/swapmsg
  42.   echo >> $TMP/swapmsg
  43.   echo "`gettext "Do you wish to install these as your swap partitions? "`" >> $TMP/swapmsg
  44.   dialog --title "SWAP SPACE DETECTED" --cr-wrap --yesno "`cat $TMP/swapmsg`" 13 70
  45.   REPLY=$?
  46.  fi
  47.  rm -f $TMP/swapmsg
  48.  if [ ! $REPLY = 0 ]; then # no
  49.     touch $TMP/SeTswapskip
  50.     exit 0
  51.  
  52. else  # yes
  53.   if cat /proc/meminfo | grep "Swap:        0        0        0" 1> $NDIR 2> $NDIR ; then
  54.    USE_SWAP=0 # swap is not currently mounted
  55.   fi
  56.  
  57.   CURRENT_SWAP="1" 
  58.   while [ ! "`echo "$SWAPLIST" | sed -n "$CURRENT_SWAP p"`" = "" ]; do 
  59.    SWAP_PART=`probe -l | fgrep "Linux swap" | sed -n "$CURRENT_SWAP p" | crunch | cut -f 1 -d ' '`
  60.    if ! cat /proc/swaps | grep $SWAP_PART 1> $REDIR 2> $REDIR ; then
  61.    echo $USE_SWAP 
  62.     dialog --title "`gettext "FORMATTING SWAP PARTITION"`" --infobox "`gettext "Formatting"` \
  63. $SWAP_PART `gettext "as a Linux swap partition (and checking for bad blocks)..."`" 4 55
  64.     mkswap -v1 -c $SWAP_PART 1> $REDIR 2> $REDIR
  65.    fi
  66.    echo "`gettext "Activating swap partition"` $SWAP_PART:"
  67.    echo "swapon $SWAP_PART"
  68.    swapon $SWAP_PART 1> $REDIR 2> $REDIR
  69.    #SWAP_IN_USE="`echo "$SWAP_PART       swap        swap        defaults   0   0"`"
  70.    #echo "$SWAP_IN_USE" >> $TMP/SeTswap
  71.    printf "%-16s %-16s %-11s %-16s %-3s %s\n" "$SWAP_PART" "swap" "swap" "defaults" "0" "0" >> $TMP/SeTswap
  72.    CURRENT_SWAP="`expr $CURRENT_SWAP + 1`"
  73.    sleep 4
  74.   done
  75.   echo "`gettext -e "Your swapspace has been configured. This information will\nbe added to your /etc/fstab:"`" >> $TMP/swapmsg
  76.   echo >> $TMP/swapmsg
  77.   cat $TMP/SeTswap >> $TMP/swapmsg 
  78.   dialog --title "`gettext "SWAP SPACE CONFIGURED"`" --exit-label OK --textbox $TMP/swapmsg 10 72
  79.   rm $TMP/swapmsg
  80.  
  81. fi  
  82. fi